extends mixins/_layout

block content
    link(href="/css/bootstrap.min.css", rel="stylesheet")
    
    body
        #wrapper
            //- 顶部导航
            include mixins/_header
            +header(navigator, 'post')
            
            #post
                p.title
                    span 你的文章
                    span 预览
                textarea#textInput(oninput="this.editor.update()")
                #preview

            include mixins/_post
            +post

            include mixins/_footer
            +footer
        script(src="/js/base.js")
        script(src="/js/markdown.js")
        script(src="/js/laydate.js")
        script.
            window.addEventListener('DOMContentLoaded',function(){
                function Editor(input, preview) {
                    this.update = function () {
                        preview.innerHTML = markdown.toHTML(input.value);
                    };
                    input.editor = this;
                    this.update();
                }
                new Editor($("textInput"), $("preview"));

                // 防止误操作页面刷新/关闭
                window.onbeforeunload=function(){
                    return false;
                }
                //提交表单
                kblog.postArticle();
            });